from django.core.management.base import BaseCommand
from apps.absent.models import AbsentType

class Command(BaseCommand):
    def handle(self, *args, **options):
        absent_types = ['事假','病假','工伤假','婚假','丧假','产假','探亲假','公假','年休假']
        absents = [] #定义空列表，用于存储模型实例
        for absent_type in absent_types:
            absents.append(AbsentType(name=absent_type))
        AbsentType.objects.bulk_create(absents) #批量创建
        self.stdout.write('考勤类型初始化成功！')